package com.atguigu.yygh.host.controller;

import com.atguigu.yygh.common.R;
import com.atguigu.yygh.host.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author DongYu Zhou
 * @date 2022/6/26 9:23
 */
@Api(description = "医院设置接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    /**
     * <img src="http://re1gghye1.hn-bkt.clouddn.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220625225617.jpg" height="150" width="150">
     *
     * @param page            第几页
     * @param limit           每页显示的条目数
     * @param hospitalQueryVo 接受的vo实体类
     * @return
     */
    @ApiOperation(value = "获取分页列表")
    @GetMapping("{page}/{limit}")
    public R index(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, HospitalQueryVo hospitalQueryVo) {

        Page<Hospital> pageModel = hospitalService.index(page, limit, hospitalQueryVo);
        return R.ok().data("pageModel", pageModel);
    }

    @ApiOperation(value = "更新上线状态")
    @GetMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable("id") String id,@PathVariable("status") Integer status){
        hospitalService.updateStatus(id,status);
        return R.ok();
    }


    @ApiOperation(value = "获取医院详情")
    @GetMapping("show/{id}")
    public R show(
            @PathVariable String id) {
        Map<String,Object> map = hospitalService.show(id);
        return R.ok().data(map);
    }





}
